import wx


from ViewBaseChart import ViewBaseChart
from DataManager import DataManager

class ViewPieChart(ViewBaseChart):
    def do_draw(self, data):
        self.axes.pie(data, autopct="%1.1f", labels=[str(i)+"star" for i in range(1,6)])

    def get_data(self):
        """
        very easy job to do:interate all the data and count
        """
        offset = self.DATA_OFFSET
        dt = DataManager.record.data
        #5 classes of things
        data = [0] * 5
        for i in dt:
            delta = i[2] - i[1]
            delta = delta.days * 3600 + delta.seconds
            data[i[offset]-1] += delta
        return data

class ViewMoodPieChart(ViewPieChart):
    DATA_OFFSET = 4

class ViewRatingPieChart(ViewPieChart):
    DATA_OFFSET = 3    
